package by.qizer.supercamp.web;

import by.qizer.supercamp.domain.Journal;
import by.qizer.supercamp.service.JournalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

/**
 * @author Pribytkoyski Alexey
 *         User: qizer
 *         Date: 08.04.12
 */
@Controller
public class JournalController {

    @Autowired
    private JournalService journalService;

    @RequestMapping("/journal")
    public String listJournal(Map<String, Object> map) {
        map.put("journal", new Journal());
        map.put("journalList", journalService.listJournal());
        return "journal";
    }

    @RequestMapping("/journaldel/{journalId}")
    public String deleteJournal(@PathVariable("journalId") Integer journalId) {
        journalService.removeJournal(journalId);
        return "redirect:/journal";
    }

}
